<!DOCTYPE html>
<html>
<head>
<title>Supplier</title>
<?php 
	include 'sethead.php';
?>
<script>
	$(document).ready(function() {
        
            // Set Loading
            $("#spinner").bind("ajaxSend", function() {
                $(this).show();
            }).bind("ajaxStop", function() {
                $(this).hide();
            }).bind("ajaxError", function() {
                $(this).hide();
            });
            
            $( "#menu_supplier" ).addClass("active");
            $( "#btClear" ).click(function(){
                $("#txtSupplierCode").val("");
                $("#txtSupplierName").val("");
                $("#txtTel").val("");
                $("#txtAddress").val("");
                $("#txtRemark").val("");
            });
            $("#btSubmit").click(function(){
                if($("#txtSupplierCode").val()==""){
                    $.Zebra_Dialog('Please input SupplierCode',{
                        'type':'warning',
                        'title':'Warning',
                        onClose:function(){
                            $("#txtSupplierCode").focus();
                        }
                    });
                    return false;
                }
                if($("#txtSupplierName").val()==""){
                    $.Zebra_Dialog('Please input SupplierName',{
                        'type':'warning'
                        ,'title':'Warning'
                        ,onClose:function(){
                            $("#txtSupplierName").focus();
                        }
                    });
                    $("#txtSupplierName").focus();
                    return false;
                }
                $('#spinner').show(); 
                $.post(
                  "conSupplier.php",
                  {
                      txtSupplierCode : $("#txtSupplierCode").val() ,
                      txtSupplierName : $("#txtSupplierName").val(),
                      txtTel: $("#txtTel").val(),
                      txtAddress : $("#txtAddress").val(),
                      txtRemark : $("#txtRemark").val()
                  },
                  function(data){
                      $('#spinner').hide(); 
                      if(data == "success"){
                          $.Zebra_Dialog('Insert Success',{'type':'confirmation','title':'Succress'});
                      }else if(data == "duplicate"){
                          $.Zebra_Dialog('SupplierCode is Duplicate',{'type':'warning','title':'Duplicate'});
                      }else{
                          $.Zebra_Dialog('Insert Error',{'type':'error','title':'Error'});
                      }
                  }
                );    
            });
            $("#btTest").click(function(){
               //$('#spinner').show(); 
               /*$.Zebra_Dialog('<strong>Zebra_Dialog</strong>, a small, compact and highly configurable dialog box plugin for jQuery', {
                    'type':     'error',
                    'title':    'test'
               }); */
               $.Zebra_Dialog('Insert Success',{'type':'confirmation','title':'Succress'});
            });
	});
</script>
</head>
<body>
<div class='main'>
<?php
	include 'menu.php'
?>
	<div class='headpage'>
		Supplier
	</div>
	<div class='bodypage'>
			<table border='0' >
				<tr>
					<td class='right'>Supplier Code : </td>
					<td><input type='text' class='text-m' id="txtSupplierCode"></td>
				</tr>
				<tr>
					<td class='right'>Supplier Name : </td>
					<td><input type='text' class='text-m' id="txtSupplierName"></td>
				</tr>
				<tr>
					<td class='right'>Tel : </td>
					<td><input type='text' class='text-m' id="txtTel"></td>
				</tr>
				<tr>
					<td class='right'>Address : </td>
					<td><input type='text' class='text-m' id="txtAddress"></td>
				</tr>
				<tr>
					<td class='right'>Remark : </td>
					<td><textarea cols='30' id="txtRemark"></textarea></td>
				</tr>
				<tr>
					<td colspan='2' align='center'>
						<button id="btSubmit">Submit</button>
						<button id="btClear">Clear</button>
                                                
					</td>
				</tr>
			</table>
	</div>
</div>
<div class='footer'>
	<?php
		include 'footer.php';
	?>
</div>
</body>
</html>

<div class="modal"><!-- Place at bottom of page --></div>